package test;

//
public class test4 {
    public static void main(String[] args) {
        //初始化数组
        int[] arr = {1, 2, 4, 5, 6, 7, 8, 9};
        //将返回的数组复制出来
        int[] copyArr = copyArr(arr, 0, 4);
        //打印复制出来的数组
        printArr(copyArr);

    }

    public static int[] copyArr(int[] arr, int start, int end) {
        //初始化返回数组的容量
        int[] newArr = new int[end - start];

        for (int i = start; i < end; i++) {
            newArr[i - start] = arr[i];
        }
        return newArr;
    }

    public static void printArr(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}

